package com.tpp.base.controller;

import com.tpp.base.service.AdminCinemaSeatService;
import com.tpp.comm.pojo.TpCinemaSeat;
import com.tpp.comm.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/s/cinemaSeat")
@Slf4j
public class AdminCinemaSeatController {

    @Resource
    private AdminCinemaSeatService adminCinemaSeatService;

    @GetMapping("/findByCinemaId")
    public Result findByCinemaId(Long cinemaId){
        return Result.success(adminCinemaSeatService.findByCinemaId(cinemaId));
    }

    @GetMapping("/findByCinemaIdGroupByX")
    public Result findByCinemaIdGroupByX(Long cinemaId){
        return Result.success(adminCinemaSeatService.findByCinemaIdGroupByX(cinemaId));
    }

    @PostMapping("/updateCinemaSeatsByCinemaGroupByX")
    public Result updateCinemaSeatsByCinemaGroupByX(@RequestBody Map<Integer, List<TpCinemaSeat>> cinemaSeats){
        try {
            adminCinemaSeatService.updateCinemaSeatsByCinemaGroupByX(cinemaSeats);
            return Result.success("修改成功");
        } catch (Exception e) {
            log.error(e.getMessage());
            return Result.fail("修改失败");
        }
    }



}
